//
//  ZJTabViewController.swift
//  BuildOnline
//
//  Created by ywy on 2018/3/1.
//  Copyright © 2018年 Wely. All rights reserved.
//

import UIKit

class ZJTabViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
         initItemAttrs()
        // 增加子视图
        addchildVC()
        // Do any additional setup after loading the view.
    }
    func initItemAttrs() {
        let item : UITabBarItem = UITabBarItem.appearance()
        item.setTitleTextAttributes([NSAttributedStringKey.font : UIFont.systemFont(ofSize: 10),NSAttributedStringKey.foregroundColor : RGBA(r: 51, g: 51, b: 51, a: 1)], for: .selected)
        item.setTitleTextAttributes([NSAttributedStringKey.font : UIFont.systemFont(ofSize: 10),NSAttributedStringKey.foregroundColor : RGBA(r: 153, g: 153, b: 153, a: 1)], for: .normal)
        self.tabBar.isTranslucent = false
    }
    // 增加子视图
    func addchildVC()
    {
        setUpChilderVC(baseVC: HomePageViewController(), tabTitle: "Today", navTitle: "Today", image: "today", selectedImage: "todaySelected")
        setUpChilderVC(baseVC: SecondViewController(), tabTitle: "Choose a birthday", navTitle: "Choose a birthday", image: "birthday", selectedImage: "birthdaySelected")
    }
    func setUpChilderVC(baseVC:UIViewController,tabTitle:String,navTitle:String,image:String,selectedImage:String)
    {
        let baseNavVC = ZJNavViewController.init(rootViewController:baseVC)
        self .addChildViewController(baseNavVC)
        baseNavVC.tabBarItem.title = tabTitle
        baseVC.navigationItem.title = navTitle
        baseNavVC.tabBarItem.image = UIImage.init(named: image)?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
        baseNavVC.tabBarItem.selectedImage = UIImage.init(named: selectedImage)?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
